package org.example.trainTicketSystem.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.example.trainTicketSystem.DTO.TrainScheduleDTO;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@TableName("train_schedule")
public class TrainSchedule {

    @TableId(type = IdType.AUTO)
    private int trainId;

    @TableField
    private String trainNumber;

    @TableField
    private String startStation;

    @TableField
    private String endStation;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @TableField
    private LocalDateTime departureTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @TableField
    private LocalDateTime arrivalTime;


    public TrainSchedule(TrainScheduleDTO trainScheduleDTO) {

        this.trainNumber=trainScheduleDTO.getTrainNumber();
        this.startStation=trainScheduleDTO.getStartStation();
        this.endStation=trainScheduleDTO.getEndStation();
        this.departureTime=trainScheduleDTO.getDepartureTime();
        this.arrivalTime=trainScheduleDTO.getArrivalTime();

    }
}
